<template>
    <div id="light">
        <van-row>
            <van-col span="24">
                <H3>客厅灯</H3>
                <van-button plain type="primary" size="normal" @click="handleLight('on')">打开客厅灯</van-button>
                <van-button plain type="primary" size="normal" style="margin-left: 30px" @click="handleLight('off')">
                    关闭客厅灯
                </van-button>
            </van-col>
            <van-col span="8">
            </van-col>
        </van-row>
    </div>
</template>

<script>
    export default {
        name: 'Light',
        data() {
            return {
                value: "",
                espUrl: "",
                // espUrl: "http://localhost/",
            }
        },
        methods: {
            handleLight(val) {
                // console.log(val);
                this.$axios.get(this.espUrl + "/light?flag=" + val).then(
                    response => {
                        console.log("请求成功了1", response.data);
                    },
                    error => {
                        console.log("请求失败了1", error.message)
                    }
                )
            }
        }
    }

</script>

<style>
    #light {
        font-family: Avenir, Helvetica, Arial, sans-serif;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-align: center;
        color: #2c3e50;
        margin-top: 150px;
    }
</style>
